﻿
@using System.Globalization;

<style type="text/css">
    .laytable-cell-1-AvatarPictureUrl {
        height: 100%;
        max-width: 100%;
    }
</style>
<div class="layui-fluid">
    <div class="layui-card">
        <div class="layui-card-header layuiadmin-card-header-auto">
            <div class="layui-form-item">
                提现列表&nbsp;&nbsp;&nbsp;
                <button class="layui-btn  layui-btn-normal layuiadmin-btn-tags" style="float:right;" lay-submit lay-filter="LAY-app-exportexcel">导出数据</button>
            </div>
        </div>
        <div class="layui-card-body">
            <table id="LAY-exchange-list" lay-filter="LAY-exchange-list"></table>
            <script type="text/html" id="layuiadmin-app-cont-tagsbar">
                <a class="layui-btn layui-btn-normal layui-btn-xs" lay-event="edit"><i class="layui-icon layui-icon-edit"></i>详情</a>
                <a class="layui-btn layui-btn-warm layui-btn-xs" lay-event="pay"><i class="layui-icon layui-icon-ok"></i>企业到付</a>
                <a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="del"><i class="layui-icon layui-icon-delete"></i>删除</a>
            </script>
        </div>
    </div>
</div>
<script type="text/html" id="activeTpl">
    <span>{{ d.IsTransfer ? '已转账' : '待转账'}}</span>
</script>

<script>
    layui.config({
        base: '../../../layuiadmin/' //静态资源所在路径
    }).extend({
        index: 'lib/index' //主入口模块
        }).use(['index', 'table'], function () {
            var index = layer.load(2, { shade: false });
            var table = layui.table
                , form = layui.form;

        //标题内容模板
        var customerTpl = function (d) {
                return '<a href="@Url.Action("Edit","User")?id=' + d.CustomerId + '">' + d.CustomerName;
        };

         //监听搜索
         layui.form.on('submit(LAY-app-exportexcel)', function (data) {
             var field = data.field;
             window.location.href = '@Url.Action("ExportExchangeExcelAll")'
         });

        //分类管理
        table.render({
            elem: '#LAY-exchange-list'
            , url: '@Html.Raw(Url.Action("ExchangeList"))' //模拟接口
            ,method:'post'
            , page: true //开启分页
            , even: true
            , limit: 15
            , limits: [15,30,50,100]
            , cols: [[
                { type: 'numbers' }
                , { field: 'Id', width: 60, title: 'ID' }
                , { field: 'CustomerName', width: 110, title: '用户', templet: customerTpl }
                , { field: 'ExchangFee', title: '金额', width: 100 }
                , { field: 'WeixinAccount', title: '微信信息', minWidth: 120, align: 'center', templet: '<div>{{d.Name}} {{d.WeixinAccount}}</div>' }
                , { field: 'IsTransfer', title: '已转账？', width: 150, templet:'#activeTpl' }
                , { field: 'Remark', title: '备注', minWidth: 100, align: 'center' }
                , { field: 'CreateTime', title: '时间', width: 180, align: 'center', templet: '<div>{{ layui.util.timeAgo(d.CreateTime) }}</div>' }
                , { title: '操作', width: 280, align: 'center',  toolbar: '#layuiadmin-app-cont-tagsbar' }
            ]]
            , text: { none: '一条数据也没有^_^' }
            , done: function () {
                layer.close(index);
            }
        });
        //监听工具条
        table.on('tool(LAY-exchange-list)', function (obj) {
            var data = obj.data;
            if (obj.event === 'del') {
                layer.confirm('确定删除？', function (index) {
                    obj.del();
                    $.post('@Url.Action("ExchangeDelete")', { id: obj.data.Id });
                    layer.close(index);
                });

            } else if (obj.event === 'edit') {
                var tr = $(obj.tr);
                  layer.open({
                    type: 2
                    , title: '编辑'
                    , content: '@Url.Action("ExchangeEdit")?id=' + data.Id
                    , area: ['500px', '500px']
                    , btn: ['确定', '取消']
                    , yes: function (index, layero) {
                        //点击确认触发 iframe 内容中的按钮提交
                        var submit = layero.find('iframe').contents().find("#layuiadmin-app-form-submit");
                        submit.click();
                    }
                });
            } else if (obj.event === 'pay') {
                layer.confirm('确定支付金额？', function (index) {
                    $.post('@Url.Action("Pay")', { id: obj.data.Id }, function (rep) {
                        if (rep.success) {
                            layer.msg('企业到付提交成功');
                        } else if (rep.error) {
                            layer.msg(rep.msg);
                        }
                        layer.close(index);
                    });
                });
            }
        });
         @*//监听搜索
        form.on('submit(LAY-app-contlist-search)', function (data) {
            var field = data.field;
            //执行重载
            table.reload('resource-list', {
                url:'@Html.Raw(Url.Action("CustomerList", "Customer"))'
                ,where: field
            });
        });*@

         //监听锁定操作
         form.on('switch(active)', function (obj) {
            var check = obj.elem.checked;
            $.post('@Url.Action("IsTransfer")', { Id: this.value, checked: check });
         })

        var $ = layui.$, active = {
            add: function () {
                window.location.href = '@Url.Action("Edit")';
            }
        }
        $('.layui-btn.layuiadmin-btn-tags').on('click', function () {
            var type = $(this).data('type');
            active[type] ? active[type].call(this) : '';
        });
    });
</script>







